﻿<Window x:Class="SnowmanConsulting.ProductKeyManager.UI.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="clr-namespace:SnowmanConsulting.ProductKeyManager.UI"
    xmlns:data="clr-namespace:SnowmanConsulting.ProductKeyManager.Data;assembly=SnowmanConsulting.ProductKeyManager.Data"
    x:Uid="MainWindow.Title" Style="{DynamicResource MainWindow}"
    Title="Product Key Manager">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/MainWindowResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ui:DecimalToPercentConverter x:Key="decimalToPercentConverter"/>
            <DataTemplate DataType="{x:Type data:Product}">
                <StackPanel Style="{StaticResource ProductItemContainer}">
                    <StackPanel.ToolTip>
                        <StackPanel>
                            <TextBlock Text="{Binding Path=Name}" />
                            <StackPanel Style="{StaticResource ProductItemSearchToolTip}">
                                <TextBlock Text="{Binding Mode=OneWay, Converter={StaticResource decimalToPercentConverter}, Path=SearchSimilarity}"/>
                                <TextBlock x:Uid="MainWindow.ProductDataTemplate.Match" Text=" Match"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel.ToolTip>
                    <StackPanel Orientation="Vertical">
                        <Image Style="{StaticResource ProductItemIcon}" Source="{Binding Path=Icon.Image}"/>
                        <TextBlock Style="{StaticResource ProductItemName}" Text="{Binding Path=Name}"/>
                        <TextBlock Style="{StaticResource ProductItemKeys}">
                            <TextBlock x:Uid="MainWindow.ProductDataTemplate.Keys" Text="Keys: "/>
                            <TextBlock Text="{Binding Path=Keys.Count}"/>
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem x:Uid="MainWindow.Menu.File" Header="_File">
                <MenuItem x:Uid="MainWindow.Menu.File.New" Name="MenuFileNew" Click="NewButtonClicked" Header="_New"/>
                <Separator/>
                <MenuItem x:Uid="MainWindow.Menu.File.Import" Name="MenuFileImport" Header="_Import" Click="FileMenuImportProductKeyManagerXmlClicked"/>
                <MenuItem x:Uid="MainWindow.Menu.File.Export" Header="E_xport">
                    <MenuItem x:Uid="MainWindow.Menu.File.Export.PKM" Name="MenuFileExportPKM" Click="FileMenuExportXmlClicked" Header="Export _PKM XML (Recommended)" />
                    <MenuItem x:Uid="MainWindow.Menu.File.Export.MSDN" Name="MenuFileExportMSDN" Click="FileMenuExportXmlClicked" Header="Export _MSDN XML" />
                    <MenuItem x:Uid="MainWindow.Menu.File.Export.XAML" Name="MenuFileExportXAML" IsEnabled="True" Click="FileMenuExportXmlClicked" Header="Export XAML (Experimental)" />
                </MenuItem>
                <Separator/>
                <MenuItem x:Uid="MainWindow.Menu.File.Exit" Name="MenuFileExit" Click="FileMenuExitClicked" Header="_Exit" />
            </MenuItem>
            <MenuItem x:Uid="MainWindow.Menu.Edit" Name="MenuEdit" IsEnabled="False" Click="EditButtonClicked" Header="_Edit" />
            <MenuItem x:Uid="MainWindow.Menu.View" Header="_View">
                <MenuItem x:Uid="MainWindow.Menu.View.Sort" Header="_Sort">
                    <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name" Header="Name">
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name.None" Name="MenuViewSortNameNone" Click="OnNameSort" Header="None" IsCheckable="True" IsChecked="True" />
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name.Asc" Name="MenuViewSortNameAsc" Click="OnNameSort" Header="Ascending" IsCheckable="True" />
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name.Dsc" Name="MenuViewSortNameDsc" Click="OnNameSort" Header="Descending" IsCheckable="True" />
                    </MenuItem>
                    <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount" Header="Key Count">
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount.None" Name="MenuViewSortKeyCountNone" Click="OnKeyCountSort" Header="None" IsCheckable="True" IsChecked="True" />
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount.Asc" Name="MenuViewSortKeyCountAsc" Click="OnKeyCountSort" Header="Ascending" IsCheckable="True" />
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount.Dsc" Name="MenuViewSortKeyCountDsc" Click="OnKeyCountSort" Header="Descending" IsCheckable="True" />
                    </MenuItem>
                </MenuItem>
            </MenuItem>
            <MenuItem x:Uid="MainWindow.Menu.Tools" Header="_Tools">
                <MenuItem x:Uid="MainWindow.Menu.Tools.Settings" Name="MenuToolsSettings" Header="Settings" Click="ToolsSettings_Click">
                    <MenuItem.Icon>
                        <Image Style="{StaticResource SettingsMenuIcon}"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Name="MenuToolsLogViewer" Header="Log Viewer" Click="MenuToolsLogViewer_Click"/>
            </MenuItem>
            <MenuItem x:Uid="MainWindow.Menu.Help" Header="_Help">
                <MenuItem x:Uid="MainWindow.Menu.Help.About" Name="MenuHelpAbout" Header="_About" Click="MenuHelpAboutClicked">
                    <MenuItem.Icon>
                        <Image Style="{StaticResource AboutMenuIcon}"/>
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
        </Menu>
        <ToolBarTray DockPanel.Dock="Bottom" IsLocked="True">
            <ToolBar>
                <Button Click="NewButtonClicked">
                    <Image Style="{StaticResource NewToolbarIcon}"/>
                    <Button.ToolTip>
                        <StackPanel>
                            <Label x:Uid="MainWindow.NewProductButton.ToolTip.Title" Style="{StaticResource ToolTipTitle}">
                                New
                            </Label>
                            <TextBlock x:Uid="MainWindow.NewProductButton.ToolTip.Description" Style="{StaticResource ToolTipTextBlock}">
						Add a new product and key(s)
                            </TextBlock>
                        </StackPanel>
                    </Button.ToolTip>
                </Button>
                <Separator/>
                <Button Name="toolbEdit" IsEnabled="False" Click="EditButtonClicked">
                    <Image Style="{StaticResource RenameToolbarIcon}"/>
                    <Button.ToolTip>
                        <StackPanel>
                            <Label x:Uid="MainWindow.EditProductButton.ToolTip.Title" Style="{StaticResource ToolTipTitle}">
                                Edit
                            </Label>
                            <TextBlock x:Uid="MainWindow.EditProductButton.ToolTip.Description" Style="{StaticResource ToolTipTextBlock}">
						Edit the selected product and add or remove keys.
                            </TextBlock>
                        </StackPanel>
                    </Button.ToolTip>
                </Button>
                <Separator/>
                <Button Click="DeleteButtonClicked">
                    <Image Style="{StaticResource DeleteToolbarIcon}"/>
                    <Button.ToolTip>
                        <StackPanel>
                            <Label x:Uid="MainWindow.DeleteProductButton.ToolTip.Title" FontWeight="Bold" Style="{StaticResource ToolTipTitle}">
                                Delete
                            </Label>
                            <TextBlock x:Uid="MainWindow.DeleteProductButton.ToolTip.Description" Style="{StaticResource ToolTipTextBlock}">
						Permanently remove the selected product and all associated keys.
                            </TextBlock>
                        </StackPanel>
                    </Button.ToolTip>
                </Button>
            </ToolBar>
            <ToolBar>
                <TextBox Name="txtSearch" AcceptsReturn="False" KeyDown="SearchKeyDown" Style="{StaticResource SearchTextBox}"/>
                <CheckBox Name="chkSearch" Checked="OnSearch" Unchecked="OnUnSearch">
                    <Image Style="{StaticResource SearchToolbarIcon}"/>
                    <CheckBox.ToolTip>
                        <StackPanel>
                            <Label x:Uid="MainWindow.SearchProductButton.ToolTip.Title1" Style="{StaticResource ToolTipTitle}">
                                Product Search
                            </Label>
                            <TextBlock x:Uid="MainWindow.SearchProductButton.ToolTip.Description1" Style="{StaticResource ToolTipTextBlock}">
						Product Key Manager searches product names by keyword.
                            </TextBlock>
                            <Label x:Uid="MainWindow.SearchProductButton.ToolTip.Title2" Style="{StaticResource ToolTipTitle}">Example</Label>
                            <TextBlock x:Uid="MainWindow.SearchProductButton.ToolTip.Description2" Style="{StaticResource ToolTipTextBlock}">
						"small business" will return any results with both small and business.
                            </TextBlock>
                        </StackPanel>
                    </CheckBox.ToolTip>
                </CheckBox>
            </ToolBar>
        </ToolBarTray>
        <ListBox Name="listProductKeys" Style="{StaticResource ProductList}" SelectionChanged="ProductKeysList_SelectionChanged" MouseDoubleClick="ProductKeysList_DoubleClicked" KeyDown="ListBoxKeyDown"  ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
    </DockPanel>
</Window>
